package com.hiabr.iep.admin.enums;

import java.util.stream.Stream;

public enum TenantTypeEnum {
    TRIAL(0, "试用租户"),
    FORMAL(1, "正式租户"),
    ;

    public final Integer code;
    public final String name;

    TenantTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code取枚举对象
     *
     * @param code
     * @return
     */
    public static TenantTypeEnum getByCode(String code) {
        return Stream.of(TenantTypeEnum.values())
                .filter(enum_ -> enum_.code.equals(code))
                .findAny()
                .orElse(null);
    }

    public Integer getCode() {
        return code;
    }
}
